﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using SmashedApples.Core;

namespace SmashedApples.Data.Contexts
{
    public class BaseContext : IDisposable
    {

        public BaseContext()
        { 
            sqlConnection = new SqlConnection(Config.connectionString);
        }


        public SqlConnection sqlConnection;

        private SqlCommand SqlCommand;
        public SqlCommand sqlCommand
        {
            get { return SqlCommand; }
            set
            {
                SqlCommand = value;
                SqlCommand.Connection = this.sqlConnection;
            }
        }


        #region IDisposable Members


        public void Dispose()
        {

            if (sqlConnection != null)
            {
                sqlConnection.Dispose();
            }

            if (sqlCommand != null)
            {
                SqlCommand.Dispose();
            }

        }

        #endregion


    }
}
